/*
 *
400出现在数组a1的位置： 7
L1链表中存在元素: 80
它是链表中第: 9个节点
a1 数组中 500出现了: 1次
L1 容器中60出现了: 3次

 */

#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
int main(void){

	int a1[] = {100,200,300,400,500,600,700,800,900,1000};
	int *ptr = find(a1, a1+10, 800);
	cout << "400出现在数组a1的位置： " << ptr - a1 << endl;

	list<int> L1;
	int a2[] = {20,30,40,50,60,60,70,60,80};
	for(int i=0; i<sizeof(a2)/sizeof(a2[0]); i++){
		L1.push_back(a2[i]);
	}
	list<int>::iterator it;
	it = find(L1.begin(), L1.end(), 80);
	if(it != L1.end()){
		cout << "L1链表中存在元素: " << *it << endl;
		cout << "它是链表中第: " << distance(L1.begin(), it) + 1 << "个节点"<< endl;
	}

	int n1 = count(a1, a1+10, 500);
	cout << "a1 数组中 500出现了: "<<n1<< "次"<<endl;
	
	int n2 = count(L1.begin(), L1.end(), 60);
	cout << "L1 容器中60出现了: " <<n2 <<"次"<< endl;
	return 0;
}
